package zw_901_1000.zw_961_在长度2N的数组中找出重复N次的元素;

import java.util.HashMap;

class Solution {

    public static void main(String[] args) {
        int[] nums = {1,2,3,3};
        int n = repeatedNTimes(nums);
        System.out.println(n);

    }

    public static int repeatedNTimes(int[] nums) {
        int ans = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i],map.getOrDefault(nums[i],0) + 1);
            if (map.get(nums[i]) > 1) {
                ans = nums[i];
                break;
            }
        }
        return ans;
    }
}